package com.chinalife.repository

import java.sql.SQLClientInfoException

import org.springframework.beans.factory.annotation.Autowired
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate
import org.springframework.stereotype.Repository

import com.chinalife.entities.User

@Repository
class UserDao {

	@Autowired
	NamedParameterJdbcTemplate template;
	
	def findList(offset, size){
		def sql = "select id, userName, password, birthday from T_USER limit ${offset},${size}"
		template.queryForList(sql, new HashMap<String, Object>())
	}
	
	def add(user){
		def sql = "insert into T_USER(id, userName, password, birthday) values(:id, :userName, :password, :birthday)"
		template.update(sql, user)
	}
}
